import axios, { ResponseData } from './index'
import { AxiosPromise } from 'axios'

// 查询所有设备及其属性
export const getNodeview = ({ }): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/nodeview',
        method: 'GET'
    })
}

// 查询单个属性
interface getNodeParams {
    ip: any,
    name?:string
}
export const getNode = (params: getNodeParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/node',
        params,
        method: 'GET'
    })
}
// 批量修改设备
export const putNodeUpdate = (data: {}): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/node/update',
        data,
        method: 'PUT'
    })
}
// 查询单个设备密码
interface getPasswdParams {
    ip: any
}
export const getPasswd = (params: getPasswdParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/passwd',
        params,
        method: 'GET'
    })
}
// 密码删除数据库
export const getPasswdDelete = (data:{}): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/passwd/delete',
        data,
        method: 'PUT'
    })
}

// 删除设备
export const putNodeDelete = (data:{}): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/node/delete',
        data,
        method: 'PUT'
    })
}
// 从数据库删除某个团体字
export const putSnmpDelete = (data:{}): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/snmp/delete',
        data,
        method: 'PUT'
    })
}

// 查询端口流量
interface getInterfaceParams {
    ip: any,
    fromtime: string,
    interfacename: string,
    totime: string
}
export const getInterface = (params: getInterfaceParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/interface',
        params,
        method: 'GET'
    })
}

//查询某个设备的snmp团体字信息
interface getSnmpParams {
    ip: any,
}
export const getSnmp = (params: getSnmpParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/snmp/get',
        params,
        method: 'GET'
    })
}

//开关端口
interface putInterfaceactionData {
    action: string,
    interfacename: string,
    ip: string,
    writecommunity: string
}
export const putInterfaceaction = (data: putInterfaceactionData): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/interfaceaction',
        data,
        method: 'PUT'
    })
}
//查询设备ARP信息-设备管理页面-终端按钮ip查询
interface getArpParams {
    ip: string
}
export const getArp = (params: getArpParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/arp',
        params,
        method: 'GET'
    })
}
//从数据库查询lldp邻居信息-设备管理页面-拓扑按钮
interface getLldpParams {
    ip: string
}
export const getLldp = (params: getLldpParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/lldp',
        params,
        method: 'GET'
    })
}
//查询设备配置文件列表
interface getCfgipParams {
    ip: string
}
export const getCfgip = (params: getCfgipParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/cfgip',
        params,
        method: 'GET'
    })
}
//
// 查询设备配置文件
interface getCfgParams {
    ip: string,
    date: string
}
export const getCfg = (params: getCfgParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/cfg',
        params,
        method: 'GET'
    })
}
// 比对设备配置文件
interface getCfgcompareParams {
    ip: string,
    date1: string,
    date2: string,
}
export const getCfgcompare = (params: getCfgcompareParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/cfgcompare',
        params,
        method: 'GET'
    })
}
// 用户列表
export const getUser = ({}): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/user',
        method: 'GET'
    })
}

// 创建用户
interface putUserCreateData {
    email?: string,
    password: string,
    username: string,
}
export const putUserCreate = (params: putUserCreateData): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/user/create',
        params,
        method: 'PUT'
    })
}
// 删除用户
interface putUserDeleteParams {
    username: string,
}
export const putUserDelete = (params: putUserDeleteParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/user/delete',
        params,
        method: 'PUT'
    })
}
// 更新用户
interface putUserUpdateParams {
    username: string,
    email?:string,
    password?:string
}
export const putUserUpdate = (params: putUserUpdateParams): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/user/update',
        params,
        method: 'PUT'
    })
}
// nvisual配置查询
export const getNvisual = ({}): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/nvisual',
        method: 'GET'
    })
}
// nvisual配置更新
export const putNvisualUpdate = (data:{}): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/nvisual/update',
        data,
        method: 'PUT'
    })
}

// 新增/修改设备属性oid配置信息
export const putpropertyoidInsert = (data:{}): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/propertyoid/insert',
        data,
        method: 'PUT'
    })
}
// 删除设备属性oid配置信息
export const putpropertyoidDelete = (data:{}): AxiosPromise<ResponseData> => {
    return axios.request({
        url: '/wlpz/propertyoid/delete',
        data,
        method: 'PUT'
    })
}